package com.itcm.skymail.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.itcm.common.valid.AddGroup;
import com.itcm.common.valid.ListValue;
import com.itcm.common.valid.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * 品牌
 *
 * @author cm_fighting
 * @email cmtianxie@163.com
 * @date 2020-08-27 14:20:36
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    // 这里的规则仅为了测试设置 不需要考虑真实场景
    // 如果使用了分组校验 则校验规则上必须指定分组 否则规则不生效
    @Null(message = "新增时不能传id", groups = {AddGroup.class})
    @NotNull(message = "修改数据时id不能为空", groups = {UpdateGroup.class})
    @TableId
    private Long brandId;

    @NotBlank(message = "品牌名不能为空", groups = {AddGroup.class})
    private String name;

    @NotEmpty
    @URL(message = "必须是一个合法的url地址")
    private String logo;

    private String descript;

    @ListValue(value = {0, 1}, groups = {AddGroup.class})
    private Integer showStatus;

    @NotEmpty
    @Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须是一个字母", groups = {AddGroup.class})
    private String firstLetter;

    @NotNull   //Integer类型不能用@NotEmpty约束
    @Min(value = 0, message = "排序必须大于等于0", groups = {AddGroup.class})
    private Integer sort;
}
